﻿using Blazor.Diagrams.Core.Geometry;
using Blazor.Diagrams.Core.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ERP.Workflow.Designer.BlazorUI.Models
{
    public class FlowPortModel : PortModel
    {
        public FlowPortModel(NodeModel parent, PortAlignment alignment = PortAlignment.Bottom, Point? position = null, Size? size = null) : base(parent, alignment, position, size)
        {
        }

        public FlowPortModel(string id, NodeModel parent, PortAlignment alignment = PortAlignment.Bottom, Point? position = null, Size? size = null) : base(id, parent, alignment, position, size)
        {
        }
        public override bool CanAttachTo(PortModel port)
        {
            var jj = base.Alignment;
            bool canAttach = true;
            foreach (var link in Parent.AllLinks)
            {
                if (link.TargetNode?.Id == port.Parent.Id)
                {
                    canAttach &= false;
                }
            }
           return canAttach && base.CanAttachTo(port);
            
        }
    }
}
